package com.example.demo.web;

import com.example.demo.service.DataSourceDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@Controller
@RequestMapping
public class IndexController {

    @Autowired
    private DataSourceDetailService dataSourceDetailService;


    @RequestMapping("/getDbDetail")
    @ResponseBody
    public String getDbDetail(String dbName){
        try {
            List<Map<String,Object>> list = this.dataSourceDetailService.getAllDataSourceName(dbName);
            this.dataSourceDetailService.toWord(list,dbName);
        } catch (Exception e) {
            e.printStackTrace();
            return "生成数据库表设计文档失败";
        }
        return "生成数据库表设计文档成功";
    }
}
